import 'package:flutter/material.dart';

class RedPoint extends StatelessWidget {
  int count;
  final double offsetX;
  final double offsetY;

  RedPoint({@required this.count, this.offsetX=0, this.offsetY=0}) {
    if(null == this.count) {
      this.count = 0;
    }
  }

  @override
  Widget build(BuildContext context) {
    double countStrLength = count.toString().length.toDouble();
    return count > 0 ? Positioned(
      top: -4 + offsetY,
      right: offsetX-countStrLength*2-4,
      child: Container(
        padding: EdgeInsets.symmetric(vertical: 1, horizontal: 4.2),
        decoration: BoxDecoration(
          color: Colors.red,
          borderRadius: BorderRadius.circular(6)
        ),
        child: LimitedBox(
          maxWidth: 23,
          child: Text(count.toString(), style: TextStyle(fontSize: 10, color: Colors.white, fontFamily: 'nomal'),maxLines: 1,overflow: TextOverflow.ellipsis,),
        ),
      ),
    ) : Container();
  }
}